
package za.ac.cput.peterjohn.DesignPatternPrincipals.Behavioral.Visitor.Model;

import java.util.List;


public class SumVisitor implements NumberVisitor
{

    @Override
    public String visit(TwoElement twoElement) 
    {
        int sum = twoElement.a + twoElement.b;
        return "sum = " + sum;
    }

    @Override
    public String visit(ThreeElement threeElement)
    {
        int sum = threeElement.a + threeElement.b + threeElement.c;
        return "sum = " + sum;
    }

    @Override
    public void visit(List<NumberElement> elementList) 
    {
        for(NumberElement ne : elementList)
            ne.accept(this);
    } 
}